#!/usr/bin/env python
# -*- coding: utf-8 -*-
from cloud_resources.vms.utils import BasicConf, ComputeResourceConf, StorageResourceConf, NetworkResourceConf
from kuberCloudTest.cloud_resources.vms.vm_operation import createVm
from kuberCloudTest.infrastructures.zone import changeZone
from kuberCloudTest.kuberCloud import KuberCloudSDK

cloud_sdk = KuberCloudSDK('MGQ5OTAwMTUyZTI1NGVk',
                          'TUdRNU9UQXdNVFV5WlRJMU5HVmtza3l3aW4wOTQ2',
                          '192.168.20.31',
                          '38080')
access_token = cloud_sdk.getAccessToken()
changeZone(access_token, '49c009ae45f546038ca87658bffca11b')
# print(getZone(access_token))


basicConf = BasicConf('SDK测试2222',
                      number=1,
                      labelIds='85d3e477cc4c4a518889a8a5b157850b,855f438d11d04b99a92d845c5e42b92b',
                      remark='SDK测试222',
                      clockOffset='localtime',
                      vmLevel=1,
                      consoleMode=1,
                      usbRedirect=True,
                      start=True,
                      sshKey='',
                      userData='',
                      version='',
                      encrypt=False)
computeResourceConf = ComputeResourceConf('7076c2db7f0d4fb786484c38f985ad30',
                                          '5356c0013433430e9689b4df36d01044',
                                          videoCount=1,
                                          videoModelType='qxl',
                                          videoModelVram=65536,
                                          videoModelRam=65536,
                                          rootPreAllocation='off',
                                          rootDiskSpecId='4873f05ecdd84a838e8413b94537a1ce',
                                          dataPreAllocation='off',
                                          dataDiskSpecId=['59040dd86337449d9febb4be71b16098', '8e22c0c33342451995ee3a3bae16c0af'],
                                          isoid=['dc770825b60043eab39048403a38320e', 'd9890d7ba490486e834f3e0faa7d879c', '605918e5158640fa87559bf3698877b5'],
                                          gpuSpec='',
                                          vgpuSpec=''
                                          )
# storageResourceConf = StorageResourceConf(allocatorStrategy=1, msid='', dataMsid='')
storageResourceConf = StorageResourceConf(allocatorStrategy=2,
                                          msid='b6d918d3b230463787f401bc71e06c7d',
                                          dataMsid='b6d918d3b230463787f401bc71e06c7d')
networkResourceConf = NetworkResourceConf(['93d57bef8da740c69666082fb36f568a', '14a3c47ec1e34aac855d3e8da09949bf'])

createVm(access_token, basicConf, computeResourceConf, storageResourceConf, networkResourceConf)
